package com.hsytech.dijiebao.account;


import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hsytech.dijiebao.R;
import com.hsytech.dijiebao.base.BaseActivity;
import com.hsytech.dijiebao.utils.Constants;

public class ForgetPasswordActivity extends BaseActivity {
	private ImageButton top_back_btn;
	private Button bar_right_top_btn;
	private TextView bar_title_tv;
	private EditText email;
	private LinearLayout finish, top_bak_liner;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_find_password);
		initView();
	}

	private boolean checkBeforePost() {

		if (email.getText().toString().equals("")) {
			showToast("����д����");
			return false;
		}
		return true;
	}

	private void initView() {
		initTitle();
		initBody();

	}

	private void initBody() {
		email = (EditText) findViewById(R.id.email);
		finish = (LinearLayout) findViewById(R.id.finish);
		finish.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				if (checkBeforePost()) {
					postHttp();

				}
			}
		});
	}

	private void initTitle() {
		top_back_btn = (ImageButton) findViewById(R.id.top_back_btn);
		top_back_btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		bar_right_top_btn = (Button) findViewById(R.id.bar_right_top_btn);
		bar_right_top_btn.setVisibility(View.GONE);
		bar_title_tv = (TextView) findViewById(R.id.bar_title_tv);
		bar_title_tv.setText("�һ�����");
		top_bak_liner = (LinearLayout) findViewById(R.id.top_bak_liner);
		top_bak_liner.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();

			}
		});
		
	}

	private void postHttp() {
		// ����
//		RequestParams data = new RequestParams();
//		data.put("user_name", email.getText().toString());
//		// data.put("token", SharedPreferencesTools.getTOKEN(this));
//		HttpUtils.post(Constants.HTTP_FIND_PASSWORD, ForgetPasswordActivity.this, data, new JsonResponseHandler() {
//			@Override
//			public void onSuccess(JSONObject data) {
//
//				finish();
//
//				Log.d("mylog", data.optString("result"));
//				// String mes = String.valueOf(data.optJSONObject("password"));
//
//				// Log.d("mylog", mes);
//				// new Handler().postDelayed(new Runnable() {
//				// @Override
//				// public void run() {
//				// Intent intent = new Intent(SignUpActivity.this,
//				// ConsummateActivity.class);
//				// intent.putExtra("registeredNum",
//				// SignUpActivity.class.getSimpleName());
//				// startActivity(intent);
//				// }
//				// }, 500);
//
//			}
//
//			@Override
//			public void onError(String mess) {
//				// TODO Auto-generated method stub
//				super.onError(mess);
//				showToast(mess);
//			}
//
//			@Override
//			public void onFailure(int statusCode, Throwable throwable) {
//				Log.d("mylog", "" + statusCode);
//				super.onFailure(statusCode, throwable);
//			}
//		});
	}
}
